<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		.item{
			width: 50px;height: 50px;background-color: red;text-align: center;color: white;line-height: 50px;position: absolute;left: 0px;top: 0px;
		}
		body{margin: 0;position: relative;}
	</style>
</head>
<body>
	<div class="item">1</div>
	<div class="item">2</div>
	<div class="item">3</div>
	<div class="item">4</div>
	<div class="item">5</div>
	<div class="item">6</div>
	<div class="item">7</div>
	<div class="item">8</div>
	<div class="item">9</div>
	<div class="item">10</div>
	<div class="item">11</div>
	<div class="item">12</div>
	<div class="item">13</div>
	<div class="item">14</div>
	<div class="item">15</div>
	<div class="item">16</div>
	<div class="item">17</div>
	<div class="item">18</div>
	<div class="item">19</div>
	<div class="item">20</div>
</body>
<script type="text/javascript">
var divS=document.getElementsByClassName("item");
document.onmousemove = function(ev){
	var x = ev.clientX;
	var y = ev.clientY;
	divS[0].style.left = x + "px";
	divS[0].style.top = y + "px";
	divS[0].style.marginLeft=-1*(divS[0].offsetWidth/2)+"px";
	divS[0].style.marginTop=-1*(divS[0].offsetHeight/2)+"px";
	for (var i = divS.length-1; i > 0; i--) {
		divS[i].style.left = divS[i - 1].style.left;
		divS[i].style.top = divS[i - 1].style.top;
		divS[i].style.marginLeft=-1*(divS[i].offsetWidth/2)+"px";
		divS[i].style.marginTop=-1*(divS[i].offsetHeight/2)+"px";
	}
}
</script>
</html>